import router from "./router";
import { useEffect } from "react";
import { useLocation, useNavigate, useRoutes } from "react-router-dom";
import { getToken } from "./utils/auth";

// 配置路由规则
function App() {
  let location = useLocation();
  let navigate = useNavigate();

  useEffect(() => {
    if (!getToken() && location.pathname !== "/login") {
      navigate("/login");
    }
  }, [location.pathname]);
  return (
    <div style={{ height: "100%" }}>

        {useRoutes(router)}
    </div>
  );
}

export default App;
